<template>
  <div v-loading="loading">
    <el-form
      :model="queryParams"
      ref="queryRef"
      :inline="true"
      v-show="showSearch"
      label-width="90px"
    >
      <el-form-item label="状态" prop="status">
        <el-select
          v-model="queryParams.status"
          placeholder="请选择状态"
          clearable
          filterable
          style="width: 240px"
        >
          <el-option
            v-for="(item, index) in report_work_status"
            :key="index"
            :label="item.label"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table
      v-loading="loading"
      :data="tableData"
      border
      style="width: 100%"
      @selection-change="handleSelectionChange"
    >
      <el-table-column width="100" label="投料批号" prop="feedingBatchNo" />
      <el-table-column width="100" label="投入数量（米）" prop="inputQty" />
      <el-table-column width="100" label="投料时间" prop="feedingTime" />
      <el-table-column width="100" label="收卷时间" prop="rollingTime" />
      <el-table-column width="100" label="产出批号" prop="outputBatchNo" />
      <el-table-column width="100" label="产出数量" prop="outputQyt" />
      <el-table-column width="100" label="有效数量（米）" prop="effectiveQyt" />
      <el-table-column width="100" label="损耗（米）" prop="loss" />
      <!-- <el-table-column width="100" label="投产比" prop="inputProdRate" /> -->
      <el-table-column width="100" label="投产比" prop="inputProdRate">
        <template #default="scope">
          <span v-if="scope.row.inputProdRate || scope.row.inputProdRate == 0">
            {{ scope.row.inputProdRate }}%
          </span>
          <span v-else>-</span>
        </template>
      </el-table-column>
      <el-table-column width="100" label="缺陷描述" prop="defectDesc" />
      <el-table-column width="100" label="质检结果" prop="testingResult">
        <template #default="scope">
          <dict-tag
            v-if="scope.row.testingResult"
            :options="quality_testing_result"
            :value="scope.row.testingResult"
          />
          <span v-else>-</span>
        </template>
      </el-table-column>
      <el-table-column width="100" label="外观判定" prop="appearanceJudgment" />
      <el-table-column width="100" label="性能判定" prop="performanceJudgment" />
      <el-table-column width="100" label="不良描述" prop="qmsDefectDesc" />
      <el-table-column width="100" label="线边仓" prop="storehouseName" />
      <el-table-column width="100" label="库位" prop="binName" />
      <el-table-column width="100" label="操作人" prop="operator" />
      <el-table-column width="100" label="记录时间" prop="recordTime" />
      <el-table-column label="状态" prop="status">
        <template #default="scope">
          <dict-tag :options="report_work_status" :value="scope.row.status" />
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- <el-table :data="tableData1" border style="width: 100%; margin-top: 10px">
      <el-table-column label="滤芯条码" prop="workOrderCode" />
      <el-table-column label="膜片型号" prop="workOrderCode" />
      <el-table-column label="产品型号" prop="workOrderCode" />
      <el-table-column label="卷膜完成时间" prop="workOrderCode" />
      <el-table-column label="立库入库时间" prop="workOrderCode" />
      <el-table-column label="卷膜是否合格" prop="workOrderCode" />
      <el-table-column label="气检结果" prop="workOrderCode" />
    </el-table> -->
  </div>
</template>

<script setup name="Data">
import { listProdReportWork } from "@/api/productionMgt/productionReport";
import { reactive, toRefs, getCurrentInstance, ref, onMounted, watch } from "vue";
const tableData = ref([]);
const { proxy } = getCurrentInstance();
const { report_work_status } = proxy.useDict("report_work_status");
const total = ref(0);
const loading = ref(false);
const showSearch = ref(true);
// const tableData1 = ref([]);
// const tableData2 = ref([]);
const props = defineProps(["datas"]);
const { datas } = toRefs(props);
const data = reactive({
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    status: undefined,
  },
});

const { quality_testing_result } = proxy.useDict("quality_testing_result");

const { queryParams } = toRefs(data);
/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
}
/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef");
  queryParams.value.status = "";
  handleQuery();
}
function getList() {
  loading.value = true;
  queryParams.value.factory = datas.value.factory;
  queryParams.value.workshopCode = datas.value.workshopCode;
  queryParams.value.productLine = datas.value.productLine;
  queryParams.value.sectionCode = datas.value.sectionCode?.join(",");
  queryParams.value.classesCode = datas.value.classesCode;
  queryParams.value.prodDate = datas.value.prodDate;
  listProdReportWork(queryParams.value).then((response) => {
    tableData.value = response.rows;
    total.value = response.total;
    loading.value = false;
  });
}
getList();
watch(datas, (val) => {
  console.log(val, "=====openOrder");
});

onMounted(async () => {});
</script>
<style lang="scss" scoped></style>
